package model;

import java.awt.Color;

public abstract class AbstractPlayer{
	protected String description;
	protected Color color;
	protected boolean turnToPlay;
	protected Slot[][] board;

	public AbstractPlayer(Color color, String description) {
		this.color = color;
		turnToPlay = false;
		this.description = description;
	}

	public boolean isTurnToPlay() {
		return turnToPlay;
	}



	public String getDescription() {
		return description;
	}

	/**
	 * Il giocatore deve implementare la sua logica di decisione in questo
	 * metodo.
	 * 
	 */
	public void takeTurn(Slot[][] board) {
		this.board = board;
		turnToPlay = true;
	}

	public void endTurn()
	{
		turnToPlay = false;
	}
	
	public abstract int executeMove();


	/**
	 * Accetta in ingresso la matrice di gioco e deve calcolare l'indice della
	 * colonna in cui inserire il proprio gettone
	 */
	// protected abstract int selectMove(Slot[][] board);

	public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	protected boolean positionIsValid(int col, Slot[][] board) {
		
		return board[0][col].equals(Slot.FREE);
	}
	
	public Slot getPlayerSlot() {
		Slot s;
		if (color.equals(Color.RED))
			s = Slot.PLAYER1;
		else
			s = Slot.PLAYER2;
		return s;
	}
	
	protected Slot getOpponentSlot() {
		Slot s;
		if (color.equals(Color.RED))
			s = Slot.PLAYER2;
		else
			s = Slot.PLAYER1;
		return s;
	}
	
	public Slot[][] getBoard()
	{
		return board;
	}
	
}
